1. Field of the Invention
This invention relates to computer systems and file storage systems. More particularly, the invention relates to a system and method for automatically reorganizing selected files to alleviate the problem of fragmentation.
2. Description of the Related Art
Computer systems use file systems to organize and store a collection of files. In different systems, files may be stored or distributed in different ways. For example, in a simple standalone personal computer system, files are generally stored on one or more disk drives of the computer system. In a more complex cluster environment, files may be distributed over multiple computer systems or mass storage devices.
Each file in the file system may be represented on a disk drive or other storage device as a plurality of data blocks. It is generally desirable for the data blocks of each file to be stored contiguously with respect to each other on a storage device. When the data blocks of a file are contiguous, input/output (I/O) operations can access the file more efficiently. However, as I/O write operations occur, files tend to become fragmented over time. For example, when new data needs to be added to a file, the computer system may allocate new data blocks in which to store the new data. Oftentimes, the new data blocks are not allocated contiguously with the existing data blocks of the file, causing the file to become fragmented.
A file system in which many files are fragmented may result in a significant performance decrease for both I/O operations that access existing files and I/O operations that create new files. Previous approaches for dealing with the problem of fragmentation have involved performing defragmentation operations in which all or a portion of the file system is defragmented in mass. This may involve performing an intensive operation to analyze the file system to determine the areas of fragmentation and to reorganize many files to eliminate the fragmentation.
The amount of time that such a mass defragmentation operation takes may depend on several factors, including the size of the volume, the number and size of files on the volume, the amount of fragmentation, and the available system resources. In general, the mass defragmentation operation is very costly and can significantly interfere with other tasks executing on the computer system. In addition, such a defragmentation operation is generally not performed until a human intervenes, e.g., until a system administrator issues a command causing the mass defragmentation operation to be performed. Thus, files remain in a fragmented state until the mass defragmentation operation is invoked by request.